//
//  Double+ZJ.swift
//  ZJSwiftKit
//
//  Created by 万孟超 on 2023/3/8.
//

import Foundation
/// Extend String with `zj` proxy.
extension Double: ZJPrefixProtocol { }

extension ZJPrefix where Base == Double {
    
    /// 时间戳转换为时间字符串
    public var toDateString : String {
        let date = Date.init(timeIntervalSince1970: base)
        let dateformat = DateFormatter()
        dateformat.dateFormat = "yyyy-MM-dd HH:mm:ss"
        return dateformat.string(from: date)
    }
    
    /// 时间戳转换为时间字符串
    public func dateString(format: String = "yyyy-MM-dd HH:mm:ss") -> String {
        let date = Date.init(timeIntervalSince1970: base)
        let dateformat = DateFormatter()
        dateformat.dateFormat = format
        return dateformat.string(from: date)
    }
    
    /// Double转换成String
    public var toString : String {
        "\(base)"
    }
}
